// pages/doctor-my-follow/doctor-my-follow.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {

    pagesize: 10,       // 显示多少行
    page: 1,            // 页数
    shoucang:"",        // 收藏列表
    imgUrl: "https://tyc-bj.cn/yc/api/attach/",
    shoucang:"",
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.shoucang();//收藏列表
  },
  //收藏列表
  shoucang:function(){
    var that = this;
    var doctorId = wx.getStorageSync('userid');
    console.log("idid", doctorId);
    wx.request({
      url: app.globalData.baseUrl + '/doctor/doctor/getCollects',
      data: {
        doctorId: doctorId,
        pagesize: that.data.pagesize,
        page: that.data.page,
      },
      method: 'POST',
      header: {
        'sign': app.globalData.sign,
        'token': app.globalData.token,
        'content-type': 'application/x-www-form-urlencoded;charset=utf-8',
      },
      success: function (res) {
        console.log("收藏详情", res.data);
        that.setData({
          shoucang:res.data.data
        });
      }
    })
  },

  //取消收藏
  deleteClick: function (e) {
    // console.log('-asdasd-',e)
    var that = this;
    var doctorId = wx.getStorageSync('userid');
    // console.log("ssss", e.currentTarget.dataset.id);
    // console.log();
    wx.request({
      url: app.globalData.baseUrl + '/doctor/doctor/deleteCollect',
      data: {
       
         id: e.currentTarget.dataset.id,
      },
      method: 'POST',
      header: {
        'sign': app.globalData.sign,
        'token': app.globalData.token,
        'content-type': 'application/x-www-form-urlencoded;charset=utf-8',
      },
      success: function (res) {
        console.log("取消收藏", res.data);
        that.shoucang();
      }
    })
  },


  // 收藏详情跳转
  entery: function(e){
    let classify;
    const id = e.currentTarget.dataset.id;
    const classifies = e.currentTarget.dataset.classify;
    if (classifies == "学术活动") { classify = 'activityId';}
    if (classifies == "品牌项目") { classify = 'itemId'; }
    if (classifies == "学术频道") { classify = 'academicId'; }
    const obj = {
      id,
      classify
    }
    wx.navigateTo({
      url: "../doctor-train-details/doctor-train-details?obj=" + JSON.stringify(obj)
    });
  }

})